/*
 * @Author: zhangguliu1234 984556209@.com
 * @Date: 2023-12-25 09:28:37
 * @LastEditors: zhangguliu1234 984556209@.com
 * @LastEditTime: 2024-03-09 19:50:54
 * @FilePath: \BED2\main\main.c
 * @Description:
 *
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
 */
#include <stdio.h>
#include <string.h>
#include "driver/gpio.h"
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "freertos/queue.h"
#include "lwip/sockets.h"
#include "lwip/dns.h"
#include "lwip/netdb.h"
#include "mqtt_client.h"
#include "led.h"
#include "esp_log.h"
#include "key.h"
#include "delay.h"
#include "my_uart.h"
#include "wifi.h"
#include "my_nvs.h"
#include "nvs_flash.h"
#include "esp_netif.h"
#include "esp_wifi.h"
#include "esp_wifi_types.h"
#include "my_smartconfig.h"
#include "my_wss.h"
#include "cJSON.h"
#include "get_time.h"
#include "CRC16.h"
#include "BedSpread.h"
#include "ota.h"
#include "LetsUserEncryptDecrypt.h"
void MyHotelOutputFunction(unsigned int HotelID, unsigned char HotelLamp, unsigned short HotelAid, unsigned char HotelScenId);
void app_main(void)
{
    led_init();
    nvs_init();
    key_init();
    ota_init();
    BedSpread_uart_init();
    xTaskCreate(bed_rx_task, "bed_rx_task", 4096, NULL, 20, &BedRXTaskHandle);
    xTaskCreate(bed_control_task, "bed_tx_task", 6144, NULL, 20, NULL);
    // Bed_Nvs_Erase_All();
    connect_to_wifi();
    mqtt_app_start();
    xTaskCreate(bed_controltime_task, "bed_controltime_task", 4096, NULL, 20, NULL);
    
    while (1)
    {
        // i = !i;
        // led_statue(i);
        vTaskDelay(2000 / portTICK_PERIOD_MS);
    }
}

// unsigned int HotelID = 0;
// unsigned char HotelLamp = '0';
// unsigned short HotelAid = 0;
// unsigned char HotelScenId = '0';
// unsigned char adv_type[5] = {0xFF, 0x7F, 0x07, 0x16};
// MyHotelOutputFunction(HotelID, HotelLamp, HotelAid, HotelScenId);
// hotel_output_cb callback = MyHotelOutputFunction;
// LetsHotel_RxIdeal(&adv_type, sizeof(adv_type), callback);
// callback(HotelID, HotelLamp, HotelAid, HotelScenId);

void MyHotelOutputFunction(unsigned int HotelID, unsigned char HotelLamp, unsigned short HotelAid, unsigned char HotelScenId)
{
    printf("HotelID = %d,HotelLamp = %c,HotelAid = %d,HotelScenId = %c 111111111\n", HotelID, HotelLamp, HotelAid, HotelScenId);
}
// NVS_KEY_NAME_MAX_SIZE
// uart_enable_intr_mask